'EViews Programming Code for Sri Lanka

wfopen  "C:\Users\Maryam\Desktop\BS Studies\PhD Thesis-II\EViews and STATA Progarm Codes\Chapter-7\Sri Lanka.wf1"

'****************************************************************************
'Group Plot for pNTpT, RER_DEF, RER_DEF_NT and aTaNT
'****************************************************************************
group gA PNT_PT AT_ANT
freeze(group_plot) gA.line(x)
group_plot.setelem(1) lcolor(black) symbol(7) lpat(1)
group_plot.setelem(2) lcolor(black) symbol(4) lpat(1)
group_plot.setelem(3) lcolor(black) symbol(1) lpat(1)
group_plot.setelem(3) lcolor(black)
group_plot.options linepat
group_plot.addtext(t) Sectoral Prices and Productivity Gap (Sri Lanka & U.S): 1981-2010
group_plot.addtext(b) Year
group_plot.addtext(l) PNT_PT
group_plot.addtext(r) AT_ANT
'************************************************************
'************************************************************
create y 1981 2010
'importing data from Excel for Sri Lanka
import  "C:\Users\Maryam\Desktop\BS Studies\PhD Thesis-II\EViews and STATA Progarm Codes\Chapter-7\Chapter 7.xlsx" range="Sri Lanka"
'***************************************************************************************************
'CASE-1: ESTIMATING BALASSA-SAMUELSON EFFECT FOR pNTpT & aTaNT
'***************************************************************************************************
'*************************************************************
'STEP 0: Tests for Unit Root in Individual Time Series
'*************************************************************
'*********************************
'Graph for Sri Lanka's pNTpT
'*********************************
                                        
genr pNTpT = pNTpT
freeze(figure_pNTpT) pNTpT.line
figure_pNTpT.addtext(t) pNTpT (Sri Lanka):  1981-2010
figure_pNTpT.addtext(b) Year
figure_pNTpT.addtext(l) pNTpT
figure_pNTpT.legend(off)
                                                 
'We see from the FIGURE that pNTpT has time trend to it.  So we would include both an intercept and a time trend in our unit root regression equations. 

'************************************************
'ADF Unit Root Test for Sri Lanka's pNTpT
'************************************************
 
freeze(table_7_8_pNTpT_adf) pNTpT.uroot(adf,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 0.  The unit root test produces a t-value of -2.13 which is greater than our 5% criterion -3.57.  Thus, at this point, we cannot reject the null of a unit root.

'Now, let's check for white noise.  To do that, I first set all the residuals = 0, then run the ADF test and finally will check for white noise.

genr resid = 0
freeze(mode=overwrite,pNTpT_adf) pNTpT.uroot(adf,const,trend,info=sic)
freeze(pNTpT_adf_correl) resid.correl
 
'Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the pNTpT series is not level stationary.

'The next thing I do is test whether the differenced series is stationary using the ADF test.  I once again begin by graphing the (differenced) series.
 
genr pNTpTdiff = d(pNTpT)
freeze(figure_pNTpTdiff) pNTpTdiff.line
figure_pNTpTdiff.addtext(t) dpNTpT (Sri Lanka):  1981-2010
figure_pNTpTdiff.addtext(b) Year
figure_pNTpTdiff.addtext(l) DpNTpT
figure_pNTpTdiff.legend(off)

'From the graph, the series clearly does not have a time trend to it. So, I would test the series for unit with an intercept only.

'So we begin the whole process over again: 

genr pNTpTdiff = d(pNTpT)
freeze(table_7_8_pNTpTdiff1_adf) pNTpTdiff.uroot(adf,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p =0.  The unit root test produces a t-value of -4.98 which is now smaller than our 5% criterion -2.97.  Thus, we may now reject the null of non-stationarity in first differenced series of pNTpT.  There is no reason to go further.  The last thing we do is to check ADF regression result for white noise.

genr resid = 0
freeze(mode=overwrite,pNTpTdiff1_adf) pNTpTdiff.uroot(adf,const,info=sic)
freeze(pNTpTdiff1_adf_correl) resid.correl

''Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the pNTpT series is I(1).

'*****************************************************
'DF-GLS Unit Root Test for Sri Lanka's pNTpT
'*****************************************************
 
freeze(table_7_8_pNTpT_dfgls) pNTpT.uroot(dfgls,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 0.  The unit root test produces a t-value of -2.11 which is greater than our 5% criterion -3.19.  Thus, at this point, we may not reject the null of unit root.

'Now let's see if the series is difference stationary or not

genr pNTpTdiff = d(pNTpT)
freeze(table_7_8_pNTpTdiff1_dfgls_d) pNTpTdiff.uroot(dfgls,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p = 0.  The unit root test produces a t-value of -5.06 which is now smaller than our 5% criterion -1.95. Thus, we may reject the null of non-stationarity in first differenced series of pNTpT.  

''Putting it all together, I conclude that the pNTpT series is I(1), a finding compatible with my ADF test results.

'*************************************************
'Graph for Sri Lanka's Productivity (aTaNT)
'*************************************************
                                        
genr aTaNT = aTaNT
freeze(figureaTaNT) aTaNT.line
figureaTaNT.addtext(t) aTaNT (Sri Lanka):  1981-2010
figureaTaNT.addtext(b) Year
figureaTaNT.addtext(l) aTaNT
figureaTaNT.legend(off)
                                                 
'We see from the FIGURE that aTaNT has time trend to it.  So we would include both an intercept and a time trend in our unit root regression equations. 

'*******************************************************
'ADF Unit Root Test for Sri Lanka's Productivity
'*******************************************************
 
freeze(table_7_8_aTaNT_adf) aTaNT.uroot(adf,trend,lag=1)

'Note that I specify lag length, p =1, for obtaining white residuals. The unit root test produces a t-value of -2.70 which is greater than our 5% criterion -3.52.  Thus, at this point, we cannot reject the null of a unit root.

'Now, let's check for white noise.  To do that, I first set all the residuals = 0, then run the ADF test and finally will check for white noise.

genr resid = 0
freeze(mode=overwrite,aTaNT_adf) aTaNT.uroot(adf,const,trend,lag=1)
freeze(aTaNT_adf_correl) resid.correl
 
'Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the aTaNT series is not level stationary.

'The next thing I do is test whether the differenced series is stationary using the ADF test.  I once again begin by graphing the (differenced) series.
 
genr aTaNTdiff = d(aTaNT)
freeze(figure_aTaNTdiff) aTaNTdiff.line
figure_aTaNTdiff.addtext(t) daTaNT (Sri Lanka):  1981-2010
figure_aTaNTdiff.addtext(b) Year
figure_aTaNTdiff.addtext(l) DaTaNT
figure_aTaNTdiff.legend(off)

'From the graph, the series clearly does not have a time trend to it. So, I would test the series for unit with an intercept only.

'So we begin the whole process over again: 

genr aTaNTdiff = d(aTaNT)
freeze(table_7_8_aTaNTdiff1_adf) aTaNTdiff.uroot(adf,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p =2.  The unit root test produces a t-value of -5.77 which is now smaller than our 5% criterion -2.98.  Thus, we may now reject the null of non-stationarity in first differenced series of aTaNT. There is no reason to go further.  The last thing we do is to check ADF regression result for white noise.

genr resid = 0
freeze(mode=overwrite,aTaNTdiff1_adf) aTaNTdiff.uroot(adf,const,info=sic)
freeze(aTaNTdiff1_adf_correl) resid.correl

''Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the aTaNT series is I(1).

'************************************************************
'DF-GLS Unit Root Test for Sri Lanka's Productivity
'************************************************************
 
freeze(table_7_8_aTaNT_dfgls) aTaNT.uroot(dfgls,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 0.  The unit root test produces a t-value of -2.63 which is greater than our 5% criterion -3.19.  Thus, at this point, we may not reject the null of a unit root.
 
'Now let's see if the series is difference stationary or not

genr aTaNTdiff = d(aTaNT)
freeze(table_7_8_aTaNT1diff1_dfgls) aTaNTdiff.uroot(dfgls,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p = 1.  The unit root test produces a t-value of -5.11 which is smaller than our 5% criterion -1.95. Thus, we may reject the null of non-stationarity in first differenced series of aTaNT.  

''Putting it all together, I conclude that the aTaNT series is I(1), a finding compatible with my ADF test results.

'*********************************************
'Single Equation Cointegration Methods
'*********************************************

'**********************************************************
''Graph the suspected cointegrated series together
'**********************************************************

'The first step is to plot a graph of the suspected series.  This is very important!

group g1 pNTpT aTaNT
freeze(figure7_8a) g1.line(x)
figure7_8a.setelem(1) lcolor(black) 
figure7_8a.setelem(2) lcolor(black) lpat(8)
figure7_8a.options linepat
figure7_8a.addtext(t) pNTpT and aTaNT (Sri Lanka & U.S): 1981-2010
figure7_8a.addtext(b) Year
figure7_8a.addtext(l) pNTpT
figure7_8a.addtext(r) aTaNT

''*******************************************************
''S1.A.Engle-Granger Approach to Cointegration
'*******************************************************
 
freeze(table_7_8_egc) g1.coint(method=eg)

'The null hypothesis will not be rejected as suggested by sample statistics.

''******************************************
''S1.B.Error Correction Model (ECM)
'*******************************************
''**********************************************
'Selecting the number of lags in the VAR
'***********************************************

'NOTE: We do this because we need to have the "right" number of lags when it comes time to estimate our VEC model and test for cointegration.

var table_7_8_var1.ls 1 4   g1
freeze(table_7_8_var1_lagtest1) table_7_8_var1.laglen(4)
freeze(table_7_8_var1_lagtest2) table_7_8_var1.testlags

'The laglength test above indicates that the VAR has 1 lag. But I had to raise the number of lags to 2 to obtain white residuals.
 
var table_7_8_var2.ls 1 2  g1
freeze(table_7_8_var2_artest1) table_7_8_var2.correl
freeze(table_7_8_var2_artest2) table_7_8_var2.qstats(12)
freeze(table_7_8_var2_artest3) table_7_8_var2.arlm(12)

'The residuals are absolutely white noise.

'We now try different lags of d(aTaNT), comparing SIC values across specifications.

genr resid = 0
equation eg.ls pNTpT c aTaNT
genr ec = resid

var table_7_8_eg2a.ls 0 0 d(pNTpT)   @  c ec(-1) d(pNTpT(-1)) d(pNTpT(-2))

var table_7_8_eg2b.ls 0 0 d(pNTpT)   @  c ec(-1) d(pNTpT(-1)) d(pNTpT(-2)) d(aTaNT(-1))

var table_7_8_eg2c.ls 0 0 d(pNTpT)   @  c ec(-1) d(pNTpT(-1)) d(pNTpT(-2)) d(aTaNT(-1)) d(aTaNT(-2))

'The evidence suggests that Model A is best.  Now we test that model for serial correlation.

var table_7_8_eg2a.ls 0 0 d(pNTpT)   @   c ec(-1) d(pNTpT(-1)) d(pNTpT(-2))
freeze(table_7_8_eg2a1_artest1) table_7_8_eg2a.correl
freeze(table_7_8_eg2a2_artest2) table_7_8_eg2a.qstats(12)
freeze(table_7_8_eg2a3_artest3) table_7_8_eg2a.arlm(12)

'The residuals are absolutely white noise.

''*************************
''Estimating EC Model  
'**************************

'We'll now take the above specified model and turn it into an ECM. We shall run NW-HAC least squares model for establishing error correction mechanism.

'We now estimate the corresponding ECM:

equation table_7_8_ecm.ls(n) d(pNTpT) c ec(-1) d(pNTpT(-1)) d(pNTpT(-2))

'Note that the SR effect is insignificant as the error correction coefficient -0.03 is statistically insignificant even at 10% significance level.

''******************************************
'Multivariate Cointegration Approach
'******************************************

''********************************************************
''Check if the VAR (2) model is dynamically stable
'*********************************************************
freeze(table_7_8_var2_varstable) table_7_8_var2.arroots(graph)

'The model is dynamically stable.

''**********************************************************************
''M1.A & M1.B: Identifying the number of cointegrating vectors
'***********************************************************************

'Having identified the appropriate number of lags to put in, I now go on to test for the appropriate number of cointegrating equations.

freeze(table_7_8_var2_coint) table_7_8_var2.coint(s,2)

'This command estimates all possible combinations of constants and trends in the level data series and the cointegrating equations. All the results indicate 0 cointegrating vectors.
'
'GENERAL NOTE:, in practice, cases 1 and 5 are rarely used. One should use case 1 only if one knows that all series have zero mean. Case 5 may provide a good fit in-sample but will produce implausible forecasts out-of-sample. As a rough guide, use case 2 if none of the series appear to have a trend. For trending series, use case 3 if you believe all trends are stochastic; if you believe some of the series are trend stationary, use case 4.

'Note that the 5 cases are identified under "Johansen cointegration test" in EViews. They run from most restrictive (no constants in either the level series or CEs) to most general (trend terms in both the level series and CEs).

'CONCLUSION:  I conclude that pNTpT and aTaNT are not cointegrated in the Sri Lanka's data.


